package com.elinkway.infinitemovies.http.parser;

import com.elinkway.infinitemovies.bean.UserMessageBean;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by xiaojian on 16-3-10.
 */
public class UserMessageParser extends LVideoMobileParser<UserMessageBean>{

    private JSONObject arr;
    private String NICK_NAME = "nick_name";
    private String IMG_URL = "img_url";
    private String UID = "uid";
    private String PHONE_NUM = "phone_num";
    private String REG_PRODUCTID = "reg_productid";
    private String MIX_COMMENT_CLOSE = "mix_comment_close";
    private String AGE = "age";
    private String CREATE_TIME = "create_time";
    private String LOGIN_PRODUCTID = "login_productid";
    private String SEX = "sex";

    @Override
    public UserMessageBean parse(JSONObject data) throws Exception {
        UserMessageBean mUserMessageBean = new UserMessageBean();
        if(arr != null) {
            JSONObject mUserData = arr;
            if(mUserData != null){
                mUserMessageBean.setNick_name(mUserData.optString(NICK_NAME));
                mUserMessageBean.setImg_url(mUserData.optString(IMG_URL));
                mUserMessageBean.setUid(mUserData.optString(UID));
                mUserMessageBean.setSex(mUserData.optString(SEX));
                mUserMessageBean.setPhone_num(mUserData.optString(PHONE_NUM));
                mUserMessageBean.setReg_productid(mUserData.optString(REG_PRODUCTID));
                mUserMessageBean.setMix_comment_close(mUserData.optString(MIX_COMMENT_CLOSE));
                mUserMessageBean.setAge(mUserData.optString(AGE));
                mUserMessageBean.setCreate_time(mUserData.optString(CREATE_TIME));
                mUserMessageBean.setLogin_productid(mUserData.optString(LOGIN_PRODUCTID));
            }
            return mUserMessageBean;
        }
        return mUserMessageBean;
    }

    @Override
    protected JSONObject getData(String data) throws JSONException {
        // TODO Auto-generated method stub
        arr = new JSONObject(data);
        data = "{\"data\":\"data\"}";
        return super.getData(data);
    }
}
